﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Beta_1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            
        }

        private void Install()
        {
            this.Cursor = Cursors.WaitCursor;
            System.Threading.Thread.Sleep(1000);
            progressBar1.Value = 20;
            toolStripProgressBar1.Value = 20;

            System.Threading.Thread.Sleep(1500);
            progressBar1.Value = 55;
            toolStripProgressBar1.Value = 55;




            System.IO.Directory.CreateDirectory(@"c:\program files\Avva Mobile Enterprise Solutions\");
            System.IO.Directory.CreateDirectory(@"c:\program files\Avva Mobile Enterprise Solutions\NHibernate Helper Kit");


            string username = System.Windows.Forms.SystemInformation.UserName;


            //////////////////////////////////////////////////////////////
            
            if(System.IO.Directory.Exists(@"c:\documents and settings\" + username + @"\my documents"))
            {
                if(System.IO.Directory.Exists(@"c:\documents and settings\" + username + @"\my documents\Visual Studio 2005\Addins"))
                {
                	Console.WriteLine("Application.StartupPath="+Application.StartupPath);
                System.IO.File.Copy(Application.StartupPath + @"\AvvaMobileNHibernateHelperKit - For Testing.AddIn", @"c:\documents and settings\" + username + @"\my documents\Visual Studio 2005\Addins\AvvaMobileNHibernateHelperKit - For Testing.AddIn", true);
                }
                else
                {
                    System.IO.Directory.CreateDirectory(@"c:\documents and settings\" + username + @"\my documents\Visual Studio 2005\Addins");
                    System.IO.File.Copy(Application.StartupPath + @"\AvvaMobileNHibernateHelperKit - For Testing.AddIn", @"c:\documents and settings\" + username + @"\my documents\Visual Studio 2005\Addins\AvvaMobileNHibernateHelperKit - For Testing.AddIn", true);
                }
            }
            else
            {
                 if(System.IO.Directory.Exists(@"c:\documents and settings\" + username + @"\belgelerim\Visual Studio 2005\Addins"))
                {
                 System.IO.File.Copy(Application.StartupPath + @"\AvvaMobileNHibernateHelperKit - For Testing.AddIn", @"c:\documents and settings\" + username + @"\belgelerim\Visual Studio 2005\Addins\AvvaMobileNHibernateHelperKit - For Testing.AddIn", true);
                }
                 else
                {
                     System.IO.Directory.CreateDirectory(@"c:\documents and settings\" + username + @"\belgelerim\Visual Studio 2005\Addins");
                     System.IO.File.Copy(Application.StartupPath + @"\AvvaMobileNHibernateHelperKit - For Testing.AddIn", @"c:\documents and settings\" + username + @"\belgelerim\Visual Studio 2005\Addins\AvvaMobileNHibernateHelperKit - For Testing.AddIn", true);
                }
            }


            //////////////////////////////////////////////////////////////
            System.IO.File.Copy(Application.StartupPath + @"\log4net.dll", @"c:\program files\Avva Mobile Enterprise Solutions\NHibernate Helper Kit\log4net.dll", true);
            System.IO.File.Copy(Application.StartupPath + @"\NHibernate.dll", @"c:\program files\Avva Mobile Enterprise Solutions\NHibernate Helper Kit\NHibernate.dll", true);
            System.IO.File.Copy(Application.StartupPath + @"\Nullables.dll", @"c:\program files\Avva Mobile Enterprise Solutions\NHibernate Helper Kit\Nullables.dll", true);
            System.IO.File.Copy(Application.StartupPath + @"\AvvaMobileNHibernateHelperKit.dll", @"c:\program files\Avva Mobile Enterprise Solutions\NHibernate Helper Kit\AvvaMobileNHibernateHelperKit.dll", true);
            
            System.Threading.Thread.Sleep(700);
            progressBar1.Value = 100;
            toolStripProgressBar1.Value = 100;
            this.Cursor = Cursors.Default;
            MessageBox.Show("You have succesfully installed the product Avva Mobile NHibernate Helper Kit BETA 1");
            toolStripButton1.Enabled = false;
            
            
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            Install();
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            new AvvaMobileNHibernateHelperKit.AboutBox().ShowDialog();
        }
    }
}
